package com.lvchen.common.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;


/**
 * Created by 律晨 on 2018/3/8.
 */
public class ContainsTwoItemGalleryView extends GalleryView{

    float x = 0 ;

    public ContainsTwoItemGalleryView(Context context) {
        super(context);
    }

    public ContainsTwoItemGalleryView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ContainsTwoItemGalleryView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        int action = ev.getAction();
        switch (action){
            case MotionEvent.ACTION_DOWN:
                x = ev.getX();
                super.onTouchEvent(ev);
                break;
            case MotionEvent.ACTION_UP:
                break;
            case MotionEvent.ACTION_CANCEL:
                break;
            case MotionEvent.ACTION_MOVE:
                float daltX = Math.abs(x - ev.getX());
                if(daltX < 1){
                    return false;
                }else {
                    return true;
                }
        }
        return false;
    }
}
